//
//  HNSH_RechargeCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/6/26.
//

#import "HNSH_RechargeCell.h"

@interface HNSH_RechargeCell ()

/* cButton */
@property (nonatomic, strong) UIButton *cButton;

@end

@implementation HNSH_RechargeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self configView];
    }
    return self;
}

- (void)configView {
    [self.contentView addSubview:self.leftLabel];
    [self.contentView addSubview:self.rightLabel];
    [self.contentView addSubview:self.cButton];
    
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(16);
        make.height.mas_equalTo(20);
    }];
    
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.left.equalTo(self.leftLabel.mas_right);
        make.height.mas_equalTo(20);
    }];
    
    [self.cButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(-16);
        make.width.height.mas_equalTo(20);
    }];
}

- (UILabel *)leftLabel {
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc]init];
        _leftLabel.text = @"";
        _leftLabel.textColor = [UIColor appGrayLabelColor];
        _leftLabel.font = [UIFont systemFontOfSize:14];
    }
    return _leftLabel;
}

- (UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc]init];
        _rightLabel.text = @"";
        _rightLabel.textColor = [UIColor appBlackLabelColor];
        _rightLabel.font = [UIFont systemFontOfSize:14];
    }
    return _rightLabel;
}

- (UIButton *)cButton {
    if (!_cButton) {
        _cButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cButton setBackgroundImage:[UIImage imageNamed:@"purse_icon_copy"] forState:UIControlStateNormal];
        WeakSelf(weakSelf);
        [[_cButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            if ([weakSelf.rightLabel.text isNotBlank]) {
                [NSString copyToShearPlateString:weakSelf.rightLabel.text];
                [kSTWindow makeToast:@"复制成功"];
            }
        }];
    }
    return _cButton;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
